#include "Stack Allocator\StackAllocator.h"
//#define USE_MEMORYPOOL
#ifdef USE_MEMORYPOOL
MemoryPoolSystem pool(0, 30, 4);
void* operator new(size_t size)
{
	return pool.Allocate(size);
}
void operator delete(void* ptr)
{
	pool.Deallocate(ptr);
}
void* operator new[](size_t size)
{
	return pool.Allocate(size);
}
void operator delete[](void* ptr)
{
	pool.Deallocate(ptr);
}
#endif

#include <iostream>
#include <list>
#include <time.h>
using namespace std;
typedef struct
{
	int a,b,c,d,e,f,g;
}struct1;
int main()
{
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	
	RE::MEM::DoubleEndedAllocator stack;
	stack.Initialize(1024 * 1024 * 1);

	cout << stack.PushFrameFront(2) << endl;
	cout << stack.PushFrameFront(2) << endl;
	cout << stack.PushFrameFront(2) << endl;
	cout << stack.PushFrameFront(2) << endl;
	stack.PopFrameFront();
	cout << stack.PushFrameFront(2) << endl;
	stack.PopFrameFront();
	stack.PopFrameFront();
	stack.PopFrameFront();
	stack.PopFrameFront();
	cout << stack.PushFrameBack(2) << endl;

	stack.Destruct();

	cin.get();
	return 0;
}

//custom alloc : 2870
//new: 16427

//second test
//custom alloc: 7459
//new: 798

//////////////////////////////////
////New algorith tests
////Based on 100 000 allocations
//custom alloc  :  227
//standart alloc:  258

////Based on 1 000 000 allocations
//TEst1
//custom alloc  :  2290
//standart alloc:  2628
//Test2
//custom: 2325
//standart alloc: 2449